<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>新职位发布</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="Hosting Store Responsive web template, Bootstrap Web Templates, Flat Web Templates, Andriod Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>

    <%--<link href="${pageContext.request.contextPath}/static/admin/assets/css/minimal.css" rel="stylesheet"/>--%>
    <%--<link href="${pageContext.request.contextPath}/static/admin/assets/css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet"/>--%>
    <link href="${pageContext.request.contextPath}/static/home/css/bootstrap.css" rel='stylesheet' type='text/css' />

    <script src="${pageContext.request.contextPath}/static/home/js/jquery-1.11.1.min.js"></script>
    <%--<script src="${pageContext.request.contextPath}/static/admin/assets/js/vendor/bootstrap/bootstrap.min.js"></script>--%>
    <!-- Custom Theme files -->
    <link href="${pageContext.request.contextPath}/static/home/css/style.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/edit_user_info_css.css" rel='stylesheet' type='text/css' />
    <!-- Custom Theme files -->

    <!-- webfonts -->
    <link href='${pageContext.request.contextPath}/static/home/css/font-awesome.css' rel='stylesheet' type='text/css'/>
    <!-- webfonts -->
    <!-- dropdown -->
    <script src="${pageContext.request.contextPath}/static/home/js/jquery.easydropdown.js"></script>
    <script src="${pageContext.request.contextPath}/static/home/js/jquery-labelauty.js"></script>

    <link href="${pageContext.request.contextPath}/static/home/css/nav.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="${pageContext.request.contextPath}/static/home/css/jquery-labelauty.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/passwordStyle.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/admin/css/sweetalert.css" rel="stylesheet">

    <link href="${pageContext.request.contextPath}/static/home/css/new_jobs.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/daterangepicker-bs3.css" rel='stylesheet' type='text/css' />
    <link href="${pageContext.request.contextPath}/static/home/css/daterangepicker-1.3.7.css" rel='stylesheet' type='text/css' />

    <!-- start-smoth-scrolling -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/move-top.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/easing.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/bootstrapValidator.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/moment.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/home/js/daterangepicker-1.3.7.js"></script>

    <script src="${pageContext.request.contextPath}/static/admin/js/sweetalert.min.js"></script>
    <!-- start-smoth-scrolling -->
    <!-- webfonts -->
    <%--<link href='http://fonts.useso.com/css?family=Ubuntu:300,400,500,700' rel='stylesheet' type='text/css'>--%>
    <!-- webfonts -->
    <!-- start-smoth-scrolling -->
    <script type="text/javascript">
        jQuery(document).ready(function($) {
            $(".scroll").click(function(event){
                event.preventDefault();
                $('html,body').animate({scrollTop:$(this.hash).offset().top},1000);
            });
        });
    </script>
    <!-- end-smoth-scrolling -->
    <style>
        ul.a { list-style-type: none;}
        li.a { display: inline-block;}
        li.a { margin: 10px 0;}
        input.labelauty + label { font: 12px "Microsoft Yahei";}
        .fadeInLeft .labelauty-checked{
            color: #FFFFFF;
        }

        small{
            position: relative;
            top: 5px;
            left:17%;
        }
        .msg{
            color: #a94442;
        }
    </style>
</head>
<!-- Header Starts Here -->
<div class="inner-banner" >
    <%@include file="../header.jsp"%>

    <div id="breadcrumb_wrapper">
        <div class="container">

            <h3><strong>新职位发布</strong></h3>
            <h6>&nbsp;</h6>

            <div class="clearfix"></div>
        </div>
    </div>
</div>
<div class="clearfix"> </div>
<!-- Header Ends Here -->

<!--Main Starts Here-->
<div class="register-content">
<div class="container">
    <div class="register register-but" >
        <form class="form-job" action="${pageContext.request.contextPath}/home/job/insertJob.action" enctype="multipart/form-data" method="post">
            <div class="register-top-grid">

                <div class="wow fadeInLeft" data-wow-delay="0.4s">
                    <span class="floatLeft">职位性质<label>*</label></span>
                    <ul class="a">
                        <li class="a"><input type="radio" name="job_property_id" value="${jobPropertyList.get(0).job_property_id}" data-labelauty="${jobPropertyList.get(0).job_property_name}" checked></li>
                        <li class="a"><input type="radio" name="job_property_id" value="${jobPropertyList.get(1).job_property_id}" data-labelauty="${jobPropertyList.get(1).job_property_name}"></li>
                        <li class="a"><input type="radio" name="job_property_id" value="${jobPropertyList.get(2).job_property_id}" data-labelauty="${jobPropertyList.get(2).job_property_name}"></li>
                    </ul>
                </div>
                <div class="wow fadeInRight form-group" data-wow-delay="0.4s">
                    <span class="floatLeft">职位名称<label>*</label></span>
                    <input id="job_name" type="text"  style="width: 83%" name="job_name" value="<c:if test="${job_name != null}">${job_name}</c:if>">
                    <c:if test="${msg == 1}">
                        <p class="msg">职位名称不能为空！</p>
                    </c:if>
                </div>

                <div class="wow fadeInRight" data-wow-delay="0.4s">
                    <span class="floatLeft">职位类别<label>*</label></span>
                        <span class="input-group-btn" >
                        <select id="industry" class="btn btn-default" name="industry" style="margin-top: 100%;" onchange="changeJobType('industry','jobType')">
                            <c:forEach items="${industryList}" var="item">
                                <option value="${item.industry_id}">${item.industry_name}</option>
                            </c:forEach>
                        </select>
                        </span>

                    <span class="input-group-btn" style="margin-left: 16%">
                        <select id="jobType" class="btn btn-default" name="job_type_id" style="margin-top: 100%;">
                            <c:forEach items="${jobTypeList}" var="item">
                                <option value="${item.job_type_id}">${item.job_type_name}</option>
                            </c:forEach>
                        </select>
                        </span>
                </div>
                <div class="wow fadeInRight" data-wow-delay="0.4s">
                    <span class="floatLeft">发布地点<label>*</label></span>
                        <span class="input-group-btn" >
                        <select id="zone" class="btn btn-default" style="margin-top: 100%;" onchange="changeCity('zone','city')">
                            <c:forEach items="${zoneList}" var="item">
                                <c:choose>
                                    <c:when test="${item.name == '广东省'}">
                                        <option value="${item.zone_id}" selected>${item.name}</option>
                                    </c:when>
                                    <c:otherwise>
                                        <option value="${item.zone_id}">${item.name}</option>
                                    </c:otherwise>
                                </c:choose>
                            </c:forEach>
                        </select>
                        </span>

                    <span class="input-group-btn" style="margin-left: 16%">
                        <select id="city" class="btn btn-default" name="city_id" style="margin-top: 100%;">
                            <c:forEach items="${cityList}" var="item">
                                <option value="${item.city_id}">${item.name}</option>
                            </c:forEach>
                        </select>
                        </span>
                </div>
                <div  class="wow fadeInLeft form-group" data-wow-delay="0.4s">
                    <span class="floatLeft">招聘要求<label>*</label></span>
                    <input id="number" type="text"  style="width:10%" class="col-md-3" name="number" value="<c:if test="${number != null}">${number}</c:if>">
                    <c:if test="${msg == 1}">
                        <p class="msg">招聘人数不能为空！</p>
                    </c:if>
                    <span class="col-md-1" style="margin-top:2%;">人</span>
                        <span class="input-group-btn col-md-3" style="margin-top: 0.6%">
                            <select id="degree_id" class="btn btn-default" name="degree_id">
                                <c:forEach items="${degreeList}" var="item">
                                    <option value="${item.degree_id}">${item.degree_name}</option>
                                </c:forEach>
                            </select>
                            含以上
                        </span>
                    <span class="col-md-3"></span>
                        <span class="input-group-btn col-md-1" style="margin-top: 0.6%">
                            <select id="work_year" class="btn btn-default" name="work_year">
                                <option value="0">经验不限</option>
                                <option value="1">一年以上</option>
                                <option value="2">两年以上</option>
                                <option value="3">三年以上</option>
                                <option value="4">四年以上</option>
                                <option value="4">五年以上</option>
                            </select>
                        </span>
                </div>




            </div>

            <div class="register-bottom-grid">
                <h3> </h3>
                <div class="wow fadeInLeft" data-wow-delay="0.4s">
                    <span class="floatLeft" style="margin-top: 0">职位月薪<label>*</label></span>
                        <span class="input-group-btn  col-md-6"  >
                        <select id="salary_type_id" class="btn btn-default" name="salary_type_id" style="margin-top: -92%">
                           <c:forEach items="${salaryTypeList}" var="item">
                               <option value="${item.salary_type_id}">${item.value}</option>
                           </c:forEach>
                        </select>
                        </span>
                    <span class="col-md-3"></span>
                    <span class="input-group-btn col-md-6"  >
                        是否显示
                        <select id="show_salary" class="btn btn-default" name="show_salary" style="margin-top: -92%">
                           <option value="0">否</option>
                           <option value="1">是</option>
                        </select>
                        </span>
                    <br><br>
                </div>

                <div class="wow fadeInLeft form-group" data-wow-delay="0.4s">
                    <span class="floatLeft">职位描述<label>*</label></span>
                    <textarea id="job_description"  rows="6" cols="48" name="job_description" value="<c:if test="${job_description != null}">${job_description}</c:if> "></textarea>
                    <c:if test="${msg == 1}">
                        <p class="msg">职位描述不能为空！</p>
                    </c:if>
                </div>

                <div class="wow fadeInLeft" data-wow-delay="0.4s">
                    <span class="floatLeft">职位标签<label>*</label></span>
                    <ul class="dowebok col-md-10 a">
                        <c:if test="${jobTagList.size()==0}">
                            <li class="a"><input type="checkbox" name="" value="0" data-labelauty="暂无亮点标签哦" checked disabled></li>
                        </c:if>
                        <c:forEach items="${jobTagList}" var="item">
                            <li class="a"><input type="checkbox" name="tag" value="${item.job_tag_id}" data-labelauty="${item.job_tag_name}"></li>
                        </c:forEach>
                    </ul>
                </div>
                <br>

                <div class="wow fadeInRight form-group" data-wow-delay="0.4s">
                    <span class="floatLeft">工作地址<label>*</label></span>
                    <input id="address" type="text" style="width: 83%" name="address" value="<c:if test="${address != null}">${address}</c:if>">
                    <c:if test="${msg == 1}">
                        <p class="msg">工作地址不能为空！</p>
                    </c:if>
                </div>

                <div class="wow fadeInRight" data-wow-delay="0.4s">
                    <span class="floatLeft" style="margin-top: 4%">发布时间<label>*</label></span>
                    <div id="reportrange" class="dateRange btn btn-default btn-sm m-r-lg">
                        <i class="fa fa-calendar"></i>
                        选择时间
                        <span id="searchDateRange"></span>
                        <b class="caret" style="margin-top: -5%"></b>
                    </div>
                </div>
                <input id="date_start_string" name="date_start_string" style="display: none" value="">
                <input id="date_end_string" name="date_end_string" style="display:none" value="">
                <div class="wow fadeInRight" data-wow-delay="0.4s">
                    <span class="floatLeft">是否发布<label>*</label></span>
                    <span class="input-group-btn">
                        <select id="is_publish" class="btn btn-default" name="is_publish" >
                           <option value="0">否</option>
                           <option value="1">是</option>
                        </select>
                        </span>
                </div>
                <span style="color: red"><strong>尊敬的客户，职位发布成功后，截止日期将无法修改，请确认信息后再发布</strong></span>

            </div>
            <div class="register-but">
                <input type="submit" value="确认并发布">
               <strong><span onclick="preview()" style="margin-left:5%;color: mediumblue;cursor: pointer " >预览职位</span></strong>
        </div>
        </form>
    </div>
</div>
</div>
<!--Main Ends Here-->


<!-- #Footer -->
<%@include file="../footer.jsp"%>
<!-- /#Footer -->
<!-- here stars scrolling icon -->
<script type="text/javascript">

    <c:if test="${error == 1}">
    alter("服务器出错！");
    </c:if>
    <c:choose>
        <c:when test="${status==0}">
            swal("","该企业账号已被封号,请联系客服了解详情","error");
        </c:when>
        <c:when test="${detailStatus==0}">
            swal("","企业信息仍在审核中!!!","error");
        </c:when>
        <c:when test="${detailStatus==2}">
            swal("","企业信息审核不通过!!!","error");
        </c:when>
    </c:choose>
    <c:if test="">

    </c:if>
    <c:if test="${success == 1}">
    swal({
        title: "",
        text: "发布成功！",
        type: "success",
        showCancelButton: false,
        closeOnConfirm: true,
        confirmButtonText: "确定"
    }, function() {
        window.location.href="${pageContext.request.contextPath}/home/job/index.action";
    });
    setTimeout(function(){
        window.location.href="${pageContext.request.contextPath}/home/job/index.action";
    },3000);
    </c:if>

    $(document).ready(function() {
        /*
         var defaults = {
         containerID: 'toTop', // fading element id
         containerHoverID: 'toTopHover', // fading element hover id
         scrollSpeed: 1200,
         easingType: 'linear'
         };
         */

        $().UItoTop({ easingType: 'easeOutQuart' });

    });


</script>

<script>
    function changeJobType(id1,id2){
        var industry_id = $('#'+id1).val();
        $.ajax({
            type:'post',
            url:'${pageContext.request.contextPath}/home/job/changeJobType.action',
            data: 'industry_id='+ industry_id,
            success:function(data){
                var string="";
                for(var i in data){
                    string += '<option value="'+data[i].job_type_id+'">'+data[i].job_type_name+'</option>';
                }
                $('#'+id2).html(string);
                $('#'+id2).trigger("chosen:updated");
            }
        })
    }
    changeCity('zone','city');
    function changeCity(id1,id2){
        var zone_id = $('#'+id1).val();
        $.ajax({
            type:'post',
            url:'${pageContext.request.contextPath}/home/job/changeCity.action',
            data: 'zone_id='+ zone_id,
            success:function(data){
                var string="";
                for(var i in data){
                    string += '<option value="'+data[i].city_id+'">'+data[i].name+'</option>';
                }
                $('#'+id2).html(string);
                $('#'+id2).trigger("chosen:updated");
            }
        })
    }
</script>

<script>
    $(document).ready(function (){
        //时间插件
//    $('#reportrange span').html('{$startDate}' + ' - ' + '{$endDate}');
        $('#reportrange').daterangepicker(
                {
                    // startDate: moment().startOf('day'),
                    //endDate: moment(),
                    //minDate: '01/01/2012',    //最小时间
//                        maxDate : moment(), //最大时间
                    dateLimit : {
                        days : 100
                    }, //起止时间的最大间隔
                    showDropdowns : true,
                    showWeekNumbers : false, //是否显示第几周
                    timePicker : false, //是否显示小时和分钟
                    timePickerIncrement : 60, //时间的增量，单位为分钟
                    timePicker12Hour : false, //是否使用12小时制来显示时间
//                    ranges : {
//                        //'最近1小时': [moment().subtract('hours',1), moment()],
//                        '今日': [moment().startOf('day'), moment()],
//                        '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
//                        '最近7日': [moment().subtract('days', 6), moment()],
//                        '最近30日': [moment().subtract('days', 29), moment()],
//                        '上个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')],
//                        '这个月': [moment().startOf('month'), moment()]
//                    },
                    opens : 'right', //日期选择框的弹出位置
                    buttonClasses : [ 'btn btn-default' ],
                    applyClass : 'btn-small btn-primary blue',
                    cancelClass : 'btn-small',
                    format : 'YYYY/MM/DD', //控件中from和to 显示的日期格式
                    separator : ' to ',
                    locale : {
                        applyLabel : '确定',
                        cancelLabel : '取消',
                        fromLabel : '起始时间',
                        toLabel : '结束时间',
                        customRangeLabel : '自定义',
                        daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                        monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',
                            '七月', '八月', '九月', '十月', '十一月', '十二月' ],
                        firstDay : 1
                    }
                }, function(start, end, label){
                    $('#reportrange span').html(start.format('YYYY/MM/DD') + ' - ' + end.format('YYYY/MM/DD'));
                    var startDate = start.format('YYYY-MM-DD HH:mm:ss');
                    var endDate = end.format('YYYY-MM-DD HH:mm:ss');
                    $('#date_start_string').val(startDate);
                    $('#date_end_string').val(endDate);
                });

        //设置日期菜单被选项  --开始--
        /*
         var dateOption ;
         if("${riqi}"=='day') {
         dateOption = "今日";
         }else if("${riqi}"=='yday') {
         dateOption = "昨日";
         }else if("${riqi}"=='week'){
         dateOption ="最近7日";
         }else if("${riqi}"=='month'){
         dateOption ="最近30日";
         }else if("${riqi}"=='year'){
         dateOption ="最近一年";
         }else{
         dateOption = "自定义";
         }
         $(".daterangepicker").find("li").each(function (){
         if($(this).hasClass("active")){
         $(this).removeClass("active");
         }
         if(dateOption==$(this).html()){
         $(this).addClass("active");
         }
         });*/
        //设置日期菜单被选项  --结束--
    });
</script>

<script>
    $(function(){
        $(':input').labelauty();
        $('.form-group').data('bootstrapValidator', null);
        $('.form-job').bootstrapValidator({
            message: 'This value is not valid',
            fields:{
                job_name:{
                    validators: {
                        notEmpty: {
                            message: '企业名称不能为空'
                        }
                    }
                },
                number:{
                    validators: {
                        notEmpty: {
                            message: '招聘人数不能为空'
                        }
                    }
                },
                job_description:{
                    validators: {
                        notEmpty: {
                            message: '职位描述不能为空'
                        }
                    }
                },
                address:{
                    validators: {
                        notEmpty: {
                            message: '工作地址不能为空'
                        }
                    }
                },
            }

        });
    });
</script>

<script>
    function preview(){
        var job_property_id = $('input:radio[name=job_property_id]:checked').val();
        var job_name = $('#job_name').val();
        var industry_name = $('#industry option:selected').text();
        var job_type_name = $('#jobType option:selected').text();
        var zone = $('#zone option:selected').text();
        var city = $('#city option:selected').text();
        var number = $('#number').val();
        var degree = $('#degree_id option:selected').text();
        var work_year = $('#work_year option:selected').text();
        var salary_type = $('#salary_type_id option:selected').text();
        var show_salary = $('#show_salary option:selected').val();
        var job_description = $('#job_description').val();
        //var tag = $('input:checkbox[name=tag]:checked').val();
        var address = $('#address').val();
        var is_publish = $('#is_publish option:selected').val();
        var startDate = $('#date_start_string').val();
        var endDate = $('#date_end_string').val();
        var str=document.getElementsByName("tag");
        var objarray=str.length;
        var chestr=[];
        for (i=0;i<objarray;i++)
        {
            if(str[i].checked == true)
            {
                chestr[i]=str[i].value;
            }
        }
       console.log(chestr);
        <%--$.ajax({--%>
            <%--type:'post',--%>
            <%--url:'${pageContext.request.contextPath}/home/job/preview.action',--%>
            <%--dataType:'json',--%>
            <%--data: {--%>
                <%--job_property_id:job_property_id,--%>
                <%--job_name:job_name,--%>
                <%--industry_name:industry_name,--%>
                <%--job_type_name:job_type_name,--%>
                <%--zone:zone,--%>
                <%--city:city,--%>
                <%--number:number,--%>
                <%--degree:degree,--%>
                <%--work_year:work_year,--%>
                <%--salary_type:salary_type,--%>
                <%--show_salary:show_salary,--%>
                <%--job_description:job_description,--%>
                <%--tag:tag,--%>
                <%--address:address,--%>
                <%--is_publish:is_publish,--%>
                <%--startDate:startDate,--%>
                <%--endDate:endDate--%>
            <%--}--%>
//        });
        if(job_name==''||number==''||job_description==''||address==''){
            swal("","请填写好基本信息！","error");
        }else{
            window.location.href="${pageContext.request.contextPath}/home/job/preview.action?job_property_id="+job_property_id+"&job_name="+job_name+"&industry_name="+industry_name+"&job_type_name="+job_type_name+"&zone="+zone+"&city="+city+"&number="+number+"&degree="+degree+"&work_year="+work_year+"&salary_type="+salary_type+"&show_salary="+show_salary+"&job_description="+job_description+"&address="+address+"&is_publish="+is_publish+"&startDate="+startDate+"&endDate="+endDate+"&chestr="+chestr+"";

        }
    }
        <%--$('#preview .preview').attr("href","${pageContext.request.contextPath}/home/job/preview.action?job_property_id="+job_property_id+"&job_name="+job_name+"&industry_name="+industry_name+"&job_type_name="+job_type_name+"&zone="+zone+"&city="+city+"&number="+number+"&degree="+degree+"&work_year="+work_year+"&salary_type="+salary_type+"&show_salary="+show_salary+"&job_description="+job_description+"&tag="+tag+"&address="+address+"&is_publish="+is_publish+"&startDate="+startDate+"&endDate="+endDate+"");--%>


</script>


<!-- //here ends scrolling icon -->
</body>
</html>
